using System.ComponentModel.DataAnnotations;

namespace Refactored.Models
{
    /// <summary>
    ///     Data transfer object for <see cref="Book" />
    /// </summary>
    public class BookDto
    {
        public BookDto()
        {
        }

        public BookDto(Book book)
        {
            BookId = book.BookId;
            UserId = book.UserId;
            Title = book.Title;
        }

        [Key]
        public int BookId { get; set; }

        [Required]
        public string UserId { get; set; }

        [Required]
        public string Title { get; set; }

        public Book ToEntity()
        {
            var todo = new Book
            {
                Title = Title,
                BookId = BookId,
                UserId = UserId,
            };

            return todo;
        }
    }
}